package me.snowiest.snowdrift.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import me.snowiest.snowdrift.entity.Archive;
import me.snowiest.snowdrift.entity.Tag;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ArchiveMapper extends BaseMapper<Archive> {
    /**
     * 插入一条Archive记录，并设置生成的主键id
     * @param archive archive记录
     * @return 影响行数
     */
    int insertArchive(Archive archive);

    int insertAssociationForArchiveAndTag(
            @Param("archiveId") Integer archiveId,
            @Param("tagId") Integer tagId
    );

    int deleteArchiveById(@Param("id") Integer id);

    int deleteAssociationByArchiveId(@Param("id") Integer id);

    int updateArchive(Archive archive);

    int updateAssociation(Archive archive);

    Archive selectArchiveById(@Param("id") Integer id);

    List<Archive> selectAllArchive();
}
